package com.heima.admin.controller.v1;

import com.heima.admin.service.ChannelService;
import com.heima.model.admin.dto.ChannelDTO;
import com.heima.model.admin.pojo.AdChannel;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理controller",tags = "频道管理controller")
public class ChannelController {
    @Autowired
    private ChannelService channelService;

    @ApiOperation(value = "根据条件分页查询",notes = "根据参数name status page size")
    @PostMapping("/list")
    public PageResponseResult findByNameAndPage(@RequestBody ChannelDTO channelDTO,@RequestHeader(value = "userId",required = false)String id){
        return channelService.findByNameAndPage(channelDTO);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel adChannel){
        return channelService.insert(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return channelService.updateChannel(adChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return channelService.deleteChannel(id);
    }

}
